version: '3.8'
services:
  stats-server:
    build: ./explore-stat
    image: java-explore-with-me/explore-stat
    container_name: explore-statistic
    ports:
      - "9090:9090"
    depends_on:
      - stats-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/explore-stat
      - SPRING_DATASOURCE_USERNAME=sa
      - SPRING_DATASOURCE_PASSWORD=password

  stats-db:
    image: postgres:14-alpine
    container_name: statistic_db
    ports:
      - "5500:5432"
    depends_on:
      - ewm-service
    volumes:
      - /var/lib/postgresql/explore-stat/
    environment:
      - POSTGRES_DB=explore-stat
      - POSTGRES_USER=sa
      - POSTGRES_PASSWORD=password

  ewm-service:
    build: ./explore-server
    image: java-explore-with-me/explore-server
    container_name: explore-server
    ports:
      - "8080:8080"
    depends_on:
      - ewm-db
    environment:
      - EXPLORESTAT_URL=http://stats-server:9090
      - SPRING_DATASOURCE_URL=jdbc:postgresql://ewm-db:5432/explore-server
      - SPRING_DATASOURCE_USERNAME=sa
      - SPRING_DATASOURCE_PASSWORD=password

  ewm-db:
    image: postgres:14-alpine
    container_name: server_db
    ports:
      - "5600:5432"
    volumes:
      - /var/lib/postgresql/explore-server/
    environment:
      - POSTGRES_DB=explore-server
      - POSTGRES_USER=sa
      - POSTGRES_PASSWORD=password
